Field of the Invention
The invention relates to a method and an apparatus for maintaining network connection, more particularly, to a method for maintaining transmission control protocol connection and a computer system using the method.
Description of Related Art
In recent years, as computer technology advances, remote control techniques are becoming increasingly popular. A user can arbitrarily perform an operation on a computer system remotely via the network. For instance, a general user can manipulate an office computer system at home via remote control to obtain the desired data or perform a remote task. A system administrator can further remotely obtain a message such as hardware status, system event, and system log of the computer system via remote control, so as to control the status of the computer system at any time and not be limited by time and space.
In the current remote control techniques, a remote computer system generally has a network card supporting a wake on LAN (WOL) function so as to still receive a remote wake-up command after entering a hibernation status or a shutdown status. When the user performs a remote operation, a WOL command is transmitted to a remote computer system via the network, such that the computer system can be waken up from a hibernation status, resume operation statuses, or change from a shutdown status to a power-on status to facilitate the user controlling the computer system remotely.
The user generally can perform WOL on the computer system which is in the hibernation or shutdown status through transmission control protocol (TCP) via the network. The computer system and the remote server may establish a connection by using a handshaking procedure of TCP when establishing the TCP connection. However, the computer system in the hibernation or shutdown status cannot instantly return an acknowledgment (ACK) packet after receiving a wake-up packet of the remote server, and at this point the remote server begins to attempt retransmission. In particular, the remote server presets a retransmission time to wait for the remote computer system to return the ACK packet. If the remote server does not receive the response of the remote computer system within the retransmission time, the remote server attempts retransmission again, and doubles the retransmission time as the number of retransmissions is increased.
For instance, referring to FIG. 1A, FIG. 1A is a schematic diagram of packet exchange of WOL executed by a TCP connection. When the computer system enters a power saving mode 130 from a normal operation mode 120, the remote server transmits a wake-up packet to wake up the computer system, wherein the preset retransmission time of the remote server is 300 milliseconds (ms). If the computer system does not return the ACK packet after receiving the wake-up packet of the remote server, the remote server attempts a first retransmission of the wake-up packet after waiting 300 ms, and doubles the retransmission time of the next wait to 600 ms; if the computer system still does not return the ACK packet after receiving the first retransmission of the wake-up packet of the remote server, the remote server attempts a second retransmission of the wake-up packet after waiting 600 ms, and doubles the retransmission time of the next wait to 1200 ms; if the computer system still does not return the ACK packet after receiving the second retransmission of the wake-up packet of the remote server, the remote server attempts a third retransmission of the wake-up packet after waiting 1200 ms; lastly, since the computer system already resumes a normal operation status (i.e., normal operation mode 120) when receiving the third retransmission of the wake-up packet of the remote server, the operating system of the computer system returns the ACK packet.
In particular, since after the wake-up packet of the remote server reaches the network card of the computer system, the computer system needs time to resume the normal operation status to answer the ACK packet, every wake-up during resuming increases the retransmission time of the remote server until the maximum allowed by the remote server (such as 1 minute for the Windows system). When the retransmission time of the remote server is increased to the maximum allowed by the system, every time the remote server executes the wake-up procedure, the remote server has to wait for the maximum of the retransmission time so as to execute the next wake-up procedure.
Referring to FIG. 1B, FIG. 1B is a schematic diagram of packet switching of WOL executed by a TCP connection using a maximum of retransmission time. When the remote server wakes up the computer system to make the computer system resume the normal operation mode 120, if the time of the computer system executing other applications is very short such that the computer system resumes the power saving mode 130 from the normal operation mode 120 again, the computer system does not answer the ACK packet to the remote server. Therefore, when the remote server reaches the maximum of the retransmission time (such as 1 minute), a first retransmission is attempted to wake up the computer system. At this point, since the remote server has no requirement to transmit data, the computer system may return to the power saving mode 130 from the normal operation mode 120 within the maximum of the retransmission time, and fail to reply the ACK packet. The above condition occurs repeatedly and after five retransmissions, the TCP connection is disconnected, and the remote server can no longer transmit the wake-up packet via the TCP connection, such that the user cannot wake up the computer system via a network.
It can be known from the above that, although the retransmission mechanism of TCP can achieve reliable connection, if such architecture is applied on WOL, disconnection may occur such that the connection becomes unreliable.